/*******************************
 * 
 * 编写人: 董书承:
 * 编写时间: 11_3_2021
 * 对应头文件: demsStr.hh
 * 实现功能:
 *  1. 分割字符串;
 * 
******************************** 
*/


# include <vector>
# include <string>
# include "demsStr.hh"
# include <iostream>

std::vector<std::string> strSplit(std::string str, std::string spStr)
{

    std::vector<std::string> resStr;
    const int strLen = str.length();
    char s[strLen+2];
    std::strcpy(s, str.c_str());
    char *p;
    p = strtok(s, spStr.c_str());
    if (p == NULL)
    {
        // std::cout << "p是空值" << std::endl;
        resStr.insert(resStr.end(), str);
        return resStr;
    }
    while(p)
    {
        std::string tmpStr(p);
        resStr.insert(std::end(resStr), tmpStr);
        p = strtok(NULL, spStr.c_str());

    }
    
    return resStr;
    

}





